﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Quanlytruongtruongtieuhoc
{
    public partial class frmIndanhsachhocsinh : Form
    {
        public frmIndanhsachhocsinh()
        {
            InitializeComponent();
        }

        private void frmIndanhsachhocsinh_Load(object sender, EventArgs e)
        {
           try
            {
                string makhoi,malop;
                string ma = frmXemdanhsachlop.mahsxem;
                makhoi=ma.Substring(0,1);
                malop=ma.Substring(2,1);
                SqlDataAdapter ap = new SqlDataAdapter("select (a.ho+' '+a.ten) as tenhs,a.gioi_tinh,a.ma_hs,d.ma_khoi,d.ma_lop,b.ma_gv,d.nam_hoc,(b.ho+' '+b.ten) as tengv,convert(char(10),a.nam_sinh,103) as nam_sinh from hoc_sinh a,giao_vien b,chu_nhiem c,lop_hoc_sinh d where a.ma_hs=d.ma_hs and c.ma_khoi=d.ma_khoi and c.ma_lop=d.ma_lop and c.ma_gv=b.ma_gv and c.ma_lop='"+malop+"' and c.ma_khoi='"+makhoi+"' and d.nam_hoc=(select max(nam_hoc) from nam_hoc)", clsKetnoi.con);
                inDanhsach hs = new inDanhsach();
                ap.Fill(hs.DataTable1);
                inDanhsachhocsinh ds = new inDanhsachhocsinh();
                ds.SetDataSource(hs);
                crystalReportViewer1.ReportSource=ds;
            }
           catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }
    }
}
